package com.weetop.aklyscan.activity;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weetop.aklyscan.R;
import com.weetop.aklyscan.bean.ChaXunBean;

public class TiJiaoDialog extends Dialog {
    private Context mContext;
    private LinearLayout ll;
    private TextView page, totalPage, model, yiru, baocun, zuixin, total, button;
    private ChaXunBean chaXunBean;
    int totalNum, number, pinpai;

    public TiJiaoDialog(Context context, ChaXunBean chaXunBean, int total, int page, int pinpai) {
        super(context, R.style.promptDialog);
        setContentView(R.layout.dialog_tijiao);
        mContext = context;
        this.chaXunBean = chaXunBean;
        this.totalNum = total;
        number = page;
        this.pinpai = pinpai;
        initVar();
        initView();
        initAttr();
        initAction();
    }

    public void initVar() {

    }

    public void initView() {
        ll = findViewById(R.id.ll);
        page = findViewById(R.id.page);
        totalPage = findViewById(R.id.totalPage);
        model = findViewById(R.id.model);
        yiru = findViewById(R.id.yiru);
        baocun = findViewById(R.id.baocun);
        zuixin = findViewById(R.id.zuixin);
        total = findViewById(R.id.total);
        button = findViewById(R.id.button);
    }

    public void initAttr() {
        page.setText("第" + number + "页");
        totalPage.setText("共" + totalNum + "页");
        model.setText("产品型号：" + chaXunBean.getGoods_model());
        if (pinpai == 1) {
            yiru.setText("历史已入数量：" + chaXunBean.getHistory_num() + "");
            baocun.setText("最新入库保存数量：" + chaXunBean.getNew_num() + "");
            zuixin.setText("最新已入库数量：" + chaXunBean.getTotal_num() + "");
        } else if (pinpai == 0) {
            yiru.setText("历史已出数量：" + chaXunBean.getHistory_num() + "");
            baocun.setText("最新出库保存数量：" + chaXunBean.getNew_num() + "");
            zuixin.setText("最新已出库数量：" + chaXunBean.getTotal_num() + "");
        } else {
            yiru.setText("历史装箱数量：" + chaXunBean.getHistory_num() + "");
            baocun.setText("装箱保存数量：" + chaXunBean.getNew_num() + "");
            zuixin.setText("最新装箱数量：" + chaXunBean.getTotal_num() + "");
        }
        total.setText(chaXunBean.getTotal_num() + "");
        if (totalNum != number) {
            ll.setBackgroundResource(R.color.transparent);
        }
    }

    public void initAction() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
